package socket.socketandserversocket;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class WriteThread implements Runnable {
    private BufferedOutputStream bos;

    public WriteThread(BufferedOutputStream bos) {
        this.bos = bos;
    }

    Scanner scanner = new Scanner(System.in);
    String s;

    @Override
    public void run() {
        while (true) {
            try {
                s = scanner.nextLine();
                bos.write(s.getBytes());
                bos.flush();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
